package io.seata.samples.tcc.action.impl;

import io.seata.samples.tcc.action.TccActionTwo;
import org.apache.dubbo.config.annotation.DubboService;
import org.apache.seata.core.context.RootContext;
import org.apache.seata.rm.tcc.api.BusinessActionContext;

/**
 * The type Tcc action two.
 *
 * @author Administrator
 */
@DubboService(version = "1.0.0", group = "tcc")
public class TccActionTwoImpl implements TccActionTwo {
    @Override
    public boolean prepare(String param) {
        String xid = RootContext.getXID();
        System.out.println("TCC 示例：TccActionTwo prepare, xid:" + xid + ", param:" + param);
        return true;
    }

    @Override
    public boolean commit(BusinessActionContext actionContext) {
        String xid = actionContext.getXid();
        System.out.println("TCC 示例：TccActionTwo commit, xid:" + xid + ", param:" + actionContext.getActionContext("param"));
        return true;
    }

    @Override
    public boolean rollback(BusinessActionContext actionContext) {
        String xid = actionContext.getXid();
        System.out.println("TCC 示例：TccActionTwo rollback, xid:" + xid + ", param:" + actionContext.getActionContext("param"));
        return true;
    }
}
